<template>
  <div class="login-container">
    <div class="bg-circle">
      <!-- 左上 -->
      <img
        class="lt"
        src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0%E7%99%BB%E9%99%86%E9%A1%B5/u3.png"
        alt=""
      >
      <!-- 左下 -->
      <img
        class="lb"
        src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0%E7%99%BB%E9%99%86%E9%A1%B5/u5.png"
        alt=""
      >
      <!-- 右上 -->
      <img
        class="rt"
        src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0%E7%99%BB%E9%99%86%E9%A1%B5/u4.png"
        alt=""
      >
      <!-- 居中 -->
    </div>
    <div class="main">
      <img
        src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0%E7%99%BB%E9%99%86%E9%A1%B5/u25.png"
        alt=""
      >
      <el-card class="da" shadow="never">
        <div class="title">
          <img
            src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0%E7%99%BB%E9%99%86%E9%A1%B5/u24.png"
            alt=""
          >
          <h2>人力资源管理</h2>
        </div>
        <!--登录表单-->
        <el-form ref="loginFrom" :model="loginFrom" :rules="loginRules">
          <el-form-item prop="tonghu">
            <el-input
              v-model="loginFrom.mobile"
              placeholder="请输入用户名"
              prefix-icon="el-icon-user-solid"
            />
          </el-form-item>
          <el-form-item prop="password">
            <el-input
              v-model="loginFrom.password"
              placeholder="请输入密码"
              prefix-icon="el-icon-lock"
            />
          </el-form-item>
          <el-form-item prop="yanzheng">
            <el-input v-model="yanzheng2" placeholder="验证码" prefix-icon="el-icon-lock">
              <template slot="append"> {{ loginFrom.yanzheng }} </template>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" style="width: 350px;" @click="loginClick">登录</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" style="width: 350px;" @click="TestButton">测试登录</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </div>
</template>
<script>
// import axios from 'axios'
import instance from '@/utils/request'
export default {
  data() {
    return {
      yanzheng2: '',
      loginFrom: {
        mobile: '',
        password: '',
        yanzheng: '9849'
      },
      loginRules: {
        mobile: [
          { required: true, message: '手机号不能为空', trigger: 'blur' },
          { pattern: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/, message: '手机格式输入错误', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '密码不能为空', trigger: 'blur' },
          { min: 6, max: 16, message: '密码最少6位，包括大写字母，小写字母，数字，特殊字符', trigger: 'blur' }
        ],
        yanzheng: [
          { required: true, message: '验证码不能为空', trigger: 'blur' },
          { pattern: /^[0-9]*$/, message: '验证码为数字', trigger: 'blur' }
        ]

      }
    }
  },
  methods: {

    // 测试登录按钮
    TestButton() {
      // 获取登录接口跨越未解决

    },
    /**
     * 登录按钮点击事件
     */
    loginClick() {
      this.$refs.loginFrom.validate((isOK) => {
        if (isOK) {
          // alert('校验通过发送登录请求')
          const url = '/sys/login'
          instance.post(url, {
            mobile: '13800000002',
            password: '123456'
          })
          // 派发user模块的loginAciton ，额外参数
          // this.$store.dispatch('模块名/方法名', this.验证的表单)
          this.$store.dispatch('user/loginAction', this.loginFrom)
        }
      })
    }
  }
}

</script>
 <style scoped lang="scss">
 .da{
width: 390px;
height: 450px;
 }
 h2{
  margin-left: 25px;
 }

 .login-container {
  position: relative;
  height: 100%;
  background-image: linear-gradient(#3fccfd, #996cfb);
  overflow: hidden;
  // 三个圆形图⽚的位置
  .bg-circle {
  .lt {
  position: absolute;
  left: 40px;
  top: 40px;
  opacity: 0.3;
  }
  .lb {
  position: absolute;
  left: -250px;
  bottom: -200px;
  }
  .rt {
  position: absolute;
  right: -70px;
  top: -200px;
  }
  }
  // 主体内容
  .main {
  // ⽔平和垂直居中
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  // 登录卡⽚
  .el-card {
  margin-left: 60px;
  // 卡⽚标题
  .title {

  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 23px;
  font-weight: 700;
  font-style: normal;
  color: rgb(67, 141, 238);
  img {
  width: 50px;
  height: 42px;
  }
  }
  // 登录表单⽂本框
  .el-input {
  width: 350px;
  height: 44px;
  // ⽂本框内容
  ::v-deep .el-input__inner {
  background-color: #f4f5fb;
  height: 44px;
  }
  // ⽂本框头部图标样式
  img {
  width: 20px;
  height: 20px;
  margin-top: 12px;
  }
  // ⽂本框尾部验证码样式
  ::v-deep .el-input-group__append {
  font-family: 'Arial Negreta', 'Arial Normal', 'Arial';
  font-weight: 700;
  font-size: 16px;
  color: #FF7733;
  // height: 44px;
  }
  }
  // 复选款样式
  .el-checkbox {
  color:#606266;
  }
  // 登录按钮样式
  .login-btn {
  width: 350px;
  }
  }
  }
 }
 </style>

